package Lecture7_7;

import java.util.Scanner;

public class SimpleFractionRecursive {

	public static void main(String[] args)
	{
		Scanner sc = new Scanner (System.in);
		System.out.println("Enter a and b numbers to find the simple fraction!");
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.printf("Your numbers: %d / %d %n" ,a , b );
		int i = 1;
		int result = doSimpleFraction(a, b, i);
		
		System.out.println("The simmple fractions is: " + result);
		System.out.print("Your reduced numbers are: " );		
		reducedNumbers(a, b, i);		
	}

	
	public static int doSimpleFraction(int a, int b, int i)
	{
		
		i++;
		if (a % i == 0 && b % i == 0)
		{
			return i;
		}
		else
		{
			return doSimpleFraction(a, b, i);
		}
		
	}	
	
		public static void reducedNumbers(int a, int b, int i)
		
		{
			
		System.out.println((a / doSimpleFraction(a, b, i)) + " / " + (b / doSimpleFraction(a, b, i)));

		
		}
	
	
	
	
}
